package main

import (
	"fmt"
	"math"
	"strings"
)

const (
	January  = iota // 0
	February        // 1
	_
	March // 3

	n1 = iota
)

// 遍历字符串
func traversalString() {
	s := "你可真棒"
	// byte
	for i := 0; i < len(s); i++ {
		fmt.Printf("%v(%c)", s[i], s[i])
	}
	fmt.Println("")

	// rune
	for _, r := range s {
		fmt.Printf("%v(%c) ", r, r)
	}
	fmt.Println("")

}

// 修改字符串

func changeStr() {
	// byte
	s1 := "hello"
	byteS1 := []byte(s1)
	byteS1[0] = 'H'
	fmt.Println(string(byteS1))

	// rune
	s2 := "你好"
	runeS2 := []rune(s2)
	runeS2[0] = '谁'
	fmt.Println(string(runeS2))
}

func main() {
	var f32 = math.MaxFloat32
	fmt.Println(f32)

	var b bool
	fmt.Println(b)

	s1 := `
    select 
    	name
	from
    	user_info
    where
    	user_id = ?`
	fmt.Println(s1)

	fmt.Println("hello " + "world")

	fmt.Printf("%s %s \n", "hello", "world")

	var s1List = strings.Split("hello world", "")
	fmt.Printf("s1List: %+v \n", s1List)

	if strings.Contains(s1, "user_info") {
		fmt.Println("user_info in s1")
	}

	if strings.HasPrefix(s1, "hello") {
		fmt.Println("s1 begins with hello.")
	}

	if strings.HasSuffix(s1, "world") {
		fmt.Println("s1 ends with hello.")
	}

	fmt.Println(strings.Index(s1, "name"))

	fmt.Println(strings.Join([]string{"hello", "world"}, " "))

	traversalString()
	changeStr()
}
